﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class SystemManage_ChangePassword : System.Web.UI.Page
{
    public event RepeaterCommandEventHandler ItemCommand;
    public List<string> Selected
    {
        get
        {
            List<string> l = new List<string>();
            foreach (RepeaterItem item in rptUSERS.Items)
            {
                CheckBox cb = item.FindControl("chkChoose") as CheckBox;
                if (cb != null && cb.Checked)
                {
                    HiddenField fld = item.FindControl("hfUSERS") as HiddenField;
                    if (fld != null)
                    {
                        string id = fld.Value;
                        l.Add(id);
                    }
                }
            }
            return l;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            AspNetPager1.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["RowCountPerPage"].ToString());
            BindRepeater();
        }
    }

    private void BindRepeater()
    {
        int pageCount, Counts;
        rptUSERS.DataSource = new BLL.USERS().GetList(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, "USERS_CODE", false, " AND USERS_CODE!='ADMIN' ", out pageCount, out Counts);
        rptUSERS.DataBind();
        AspNetPager1.RecordCount = Counts;
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        BindRepeater();
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        if (this.Selected.Count > 0)
        {
            Response.Redirect("updatepassword.aspx?code=" + this.Selected[0]);
        }
        else
        {
            Share.Alert(this.Page,"请选择用户");
        }
    }

    protected void rptUSERS_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (ItemCommand != null)
            ItemCommand(source, e);
    }
}
